//
//  PowerTableViewCell.m
//  LotteryProject
//
//  Created by 阳光 on 17/7/9.
//  Copyright © 2017年 阳光. All rights reserved.
//

#import "PowerTableViewCell.h"

@interface PowerTableViewCell ()

@property(nonatomic,strong)UILabel *numberLabel;

@property(nonatomic,strong)UIImageView *imageUrl;

@property(nonatomic,strong)UILabel *nameLabel;

@property(nonatomic,strong)UILabel *singlePushLabel;

@property(nonatomic,strong)UILabel *earningsRateLabel;

@property(nonatomic,strong)UILabel *hitRateLabel;

@end

@implementation PowerTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.numberLabel.font=FontNumber(18);

        self.imageUrl.hidden=NO;

        self.nameLabel.font=FontNumber(18);

        self.singlePushLabel.font=FontNumber(16);

        self.earningsRateLabel.font=FontNumber(16);

        self.hitRateLabel.font=FontNumber(16);

        self.backgroundColor=WhiteColor;
    }
    return self;
}

- (UILabel *)numberLabel
{
    if (!_numberLabel) {
        _numberLabel=[self getLabelWithText:@"122" font:FontNumber(18) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_numberLabel];
        [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.centerY.mas_equalTo(0);
            make.width.mas_equalTo(50);
        }];
    }
    return _numberLabel;
}

-(UIImageView *)imageUrl
{
    if (!_imageUrl) {
        _imageUrl=[UIImageView new];
        _imageUrl.backgroundColor=MainColor;
        ViewBorderRadius(_imageUrl,kmargin*5/2,1,ClearColor);
        [self.contentView addSubview:self.imageUrl];
        [_imageUrl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.numberLabel.mas_right);
            make.centerY.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(kmargin*5,kmargin*5));
        }];
    }
    return _imageUrl;
}

// nameLabel
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel=[self getLabelWithText:@"赚米米" font:FontNumber(18) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.imageUrl.mas_right).offset(kmargin*3/2);
            make.top.mas_equalTo(self.imageUrl.mas_top);
            make.width.mas_equalTo(APPW/4);
        }];
    }
    return _nameLabel;
}

// singlePushLabel
-(UILabel *)singlePushLabel
{
    if (!_singlePushLabel) {
        _singlePushLabel=[self getLabelWithText:@"推单:13中11" font:FontNumber(16) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:2];
        [self.contentView addSubview:_singlePushLabel];
        [_singlePushLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(kmargin/2);
            make.left.mas_equalTo(self.nameLabel.mas_left);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _singlePushLabel;
}

- (UILabel *)earningsRateLabel
{
    if (!_earningsRateLabel) {
        _earningsRateLabel=[self getLabelWithText:@"盈利率:172.93%" font:FontNumber(16) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_earningsRateLabel];
        [_earningsRateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.nameLabel.mas_top);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _earningsRateLabel;
}

- (UILabel *)hitRateLabel
{
    if (!_hitRateLabel) {
        _hitRateLabel=[self getLabelWithText:@"命中率:92.31%" font:FontNumber(16) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_hitRateLabel];
        [_hitRateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.singlePushLabel.mas_top);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _hitRateLabel;
}

@end
